<?php
# Consulta actual
echo "<table id=\"tablaConsultaactual\" cellspacing=\"0\" cellpadding=\"0\" class=\"formTable\">\n";

echo "<tr valign=\"top\"><td class=\"tokenContent3\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";

if (isset($row_consultas) && trim($row_consultas->tratado_por) != "") $medres = stripslashes($row_consultas->tratado_por);
else if (isset($_SESSION["user"]) && $_SESSION["user"] != "") $medres = $_SESSION["username"];

echo "<tr><td colspan=\"3\" style=\"padding: 0px 10px 4px 0px\" align=\"right\">\n";
echo "<b>Tratado hoy por:</b> ".$medres."\n";
if (!isset($hide_botonconsultasprevias) || $hide_botonconsultasprevias == 0) echo "<input type=\"button\" name=\"previasbtn\" class=\"previasBtn\" value=\"Mostrar consultas previas\" onclick=\"abrirConsultasPrevias(".$_GET["id"].");\">\n";
echo "</td></tr>\n";

echo "<tr><td colspan=\"3\" class=\"separador\">&nbsp;</td></tr>\n";

echo "<tr><td colspan=\"3\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr valign=\"top\">\n";
echo "<td width=\"99%\" class=\"paddedTd\">\n";
echo "Motivo<br><select name=\"motivoconsulta\" class=\"comboBox\"><option value=\"PRI\"".($row_consultas->motivo == "PRI" ? " selected" : "").">Primera consulta</option><option value=\"ORD\"".($row_consultas->motivo == "ORD" ? " selected" : "").">Revisi&oacute;n</option><option value=\"INV\"".($row_consultas->motivo == "INV" ? " selected" : "").">Tratamiento invasivo</option></select>\n";
echo "</td>\n";

echo "<td width=\"1%\" class=\"paddedTd\"><nobr>\n";
	echo "Fecha<br><select name=\"diaconsulta\" class=\"day_comboBox\">";
	for ($x=1; $x<=31; $x++) echo "<option value=\"".$x."\"".(intval($fechaconsulta[2]) == $x ? " selected" : "").">".$x."</option>";
	echo "</select> <select name=\"mesconsulta\" class=\"month_comboBox\">";
	foreach ($GLOBALS["meses"] as $nummes => $mes)
	{
		if ($nummes > 0)
			echo "<option value=\"".$nummes."\"".(intval($fechaconsulta[1]) == $nummes ? " selected" : "").">".ucfirst($mes)."</option>";
	}
	echo "</select> <select name=\"anoconsulta\" class=\"year_comboBox\">";
	for ($x=date("Y"); $x>=date("Y")-2; $x--) echo "<option value=\"".$x."\"".($fechaconsulta[0] == $x ? " selected" : "").">".$x."</option>";
	echo "</select>\n";
echo "</nobr></td>\n";

echo "<td width=\"1%\" class=\"paddedTd\"><nobr>\n";
	echo "Eva basal<br><select name=\"eva_basal\" class=\"comboBox\">";
	for ($x=0; $x<=10; $x++) echo "<option value=\"".$x."\"".(isset($row_consultas) && $row_consultas->eva_basal == $x ? " selected" : "").">".$x."</option>";
	echo "</select>\n";
echo "</nobr></td>\n";
echo "<td width=\"1%\" class=\"paddedTd\"><nobr>\n";
	echo "Eva movimiento<br><select name=\"eva_movimiento\" class=\"comboBox\">";
	for ($x=0; $x<=10; $x++) echo "<option value=\"".$x."\"".(isset($row_consultas) && $row_consultas->eva_movimiento == $x ? " selected" : "").">".$x."</option>";
	echo "</select>\n";
echo "</nobr></td>\n";
echo "<td width=\"1%\"><nobr>\n";
	echo "Eva pico<br><select name=\"eva_pico\" class=\"comboBox\">";
	for ($x=0; $x<=10; $x++) echo "<option value=\"".$x."\"".(isset($row_consultas) && $row_consultas->eva_pico == $x ? " selected" : "").">".$x."</option>";
	echo "</select>\n";
echo "</nobr></td>\n";

echo "</tr>\n";
echo "</table>\n";
echo "</td></tr>\n";

echo "<tr><td style=\"height: 2px; font-size: 1px\">&nbsp;</td></tr>\n";

echo "<tr valign=\"top\"><td colspan=\"3\">\n";
echo "Descripci&oacute;n<br><textarea name=\"descripcionconsulta\" rows=\"6\">".stripslashes($row_consultas->descripcion)."</textarea><br><br>\n";
echo "</td></tr>\n";

echo "<tr><td colspan=\"3\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"\">\n";

$color1 = "#dde6ec";
$color2 = "#f0f3f4";

echo "<tr><td class=\"dataCubicle1\">\n"; require("includes/explorcom.inc.php"); echo "</td></tr>\n";
echo "<tr><td class=\"dataCubicle2\">\n"; require("includes/diagnos.inc.php"); echo "</td></tr>\n";
echo "<tr><td class=\"dataCubicle1\">\n"; require("includes/planterapeut.inc.php"); echo "</td></tr>\n";
echo "<tr><td class=\"dataCubicle2\">\n"; require("includes/tratamfarma.inc.php"); echo "</td></tr>\n";
echo "<tr><td class=\"dataCubicle1\">\n"; require("includes/trataminvas.inc.php"); echo "</td></tr>\n";

echo "</table>\n";

echo "</table>\n";
echo "</td></tr>\n";
echo "</table>\n";

# Si es una consulta nueva, ponemos la fecha de hoy
if (!isset($row_consultas))
{
	# Motivo de la consula
	echo "<script>document.form1.motivoconsulta.value = 'ORD';</script>\n";

	# Fecha de la consulta
	echo "<script>document.form1.diaconsulta.value = '".date("j")."';</script>\n";
	echo "<script>document.form1.mesconsulta.value = '".date("n")."';</script>\n";
	echo "<script>document.form1.anoconsulta.value = '".date("Y")."';</script>\n";

	# Fecha del tratamiento invasivo
	echo "<script>document.form1.mestrataminvas.value = '".date("n")."';</script>\n";
	echo "<script>document.form1.anotrataminvas.value = '".date("Y")."';</script>\n";
}
else
{
	# Fecha del tratamiento invasivo
	if ($fecha_trataminvas[0] == "" || $fecha_trataminvas[0] == "0000") echo "<script>document.form1.anotrataminvas.value = '".date("Y")."';</script>\n";
	if ($fecha_trataminvas[1] == "" || $fecha_trataminvas[0] == "00") echo "<script>document.form1.mestrataminvas.value = '".date("n")."';</script>\n";
}
?>